// custom-tab-bar/index.js
const app = getApp()
Component({
  data: {
    selected: 0,
    color: "#7A7E83",
    selectedColor: "#F24660",
    list: [
      {
        "pagePath": "/pages/home_page/index",
        "text": "首页",
        "iconPath": "icon-shouye",
        "selectedIconPath": "icon-shouye"
      },
      {
        "pagePath": "/pages/package/index",
        "text": "包裹",
        "iconPath": "icon-baoguo",
        "selectedIconPath": "icon-baoguo"
      },
      {
        "pagePath": "/pages/order/index",
        "text": "订单",
        "iconPath": "icon-dingdan",
        "selectedIconPath": "icon-dingdan"
      },
      {
        "pagePath": "/pages/personal_center/index",
        "text": "我的",
        "iconPath": "icon-wode",
        "selectedIconPath": "icon-wode"
      }
    ]
  },
  onShow:function(){
    
  },
  methods: {
    switchTab(e) {
      const data = e.currentTarget.dataset
      const url = data.path
      let index = e.currentTarget.dataset.index
      app.globalData.tabbar_index=index
      this.setData({
        selected: index
      })
      wx.switchTab({ url })
    },
    init(){
      this.setData({
        selectedColor: app.dlc.gain('theme_color'),
        selected: app.globalData.tabbar_index
      })
    }
  }
})